package com.mfnote.util;

import com.mfnote.view.R;
import com.mfnote.view.hand.HandWritingActivity;
import com.mfnote.view.main.MainActivity;
import com.mfnote.view.paint.NewPaintActivity;
import com.mfnote.view.record.NewRecordActivity;
import com.mfnote.view.write.NewWriteActivity;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;

public class WidgetProvider extends AppWidgetProvider {

	@Override
	public void onReceive(Context context, Intent intent) {
		super.onReceive(context, intent);
		
	}

	@Override
	public void onUpdate(Context context, AppWidgetManager appWidgetManager,
			int[] appWidgetIds) {
		super.onUpdate(context, appWidgetManager, appWidgetIds);
		for(int i=0;i<appWidgetIds.length;i++){
			Intent intent_1 = new Intent(context,HandWritingActivity.class);
			PendingIntent pendingIntent_1  = PendingIntent.getActivity(context, 0, intent_1, 0);
			Intent intent_2 = new Intent(context,NewRecordActivity.class);
			PendingIntent pendingIntent_2  = PendingIntent.getActivity(context, 0, intent_2, 0);
			Intent intent_3 = new Intent(context,NewPaintActivity.class);
			PendingIntent pendingIntent_3  = PendingIntent.getActivity(context, 0, intent_3, 0);
			Intent intent_4 = new Intent(context,NewWriteActivity.class);
			PendingIntent pendingIntent_4  = PendingIntent.getActivity(context, 0, intent_4, 0);
			Intent intent_5 = new Intent(context,MainActivity.class);
			PendingIntent pendingIntent_5  = PendingIntent.getActivity(context, 0, intent_5, 0);
			RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_provider);
			remoteViews.setOnClickPendingIntent(R.id.iv_hand, pendingIntent_1);
			remoteViews.setOnClickPendingIntent(R.id.iv_record, pendingIntent_2);
			remoteViews.setOnClickPendingIntent(R.id.iv_paint, pendingIntent_3);
			remoteViews.setOnClickPendingIntent(R.id.iv_write, pendingIntent_4);
			remoteViews.setOnClickPendingIntent(R.id.iv_main, pendingIntent_5);
			appWidgetManager.updateAppWidget(appWidgetIds[i], remoteViews);
		}
	}
   
}
